<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>路径</title>
	</head>

	<body>
		<canvas id="canvas" width="300" height="300"></canvas>

		<script type="text/javascript">
			function drawPath() {
				const canvasRef = document.querySelector('#canvas')
				if (!canvasRef.getContext) return
				const ctx = canvasRef.getContext('2d')
				ctx.beginPath()
				ctx.moveTo(50, 50)
				ctx.lineTo(200, 50)
				ctx.lineTo(200, 200)

				ctx.closePath()
				ctx.stroke()

				// ctx.fill();  // 如果没有自动闭合，会自动闭合。
			}

			drawPath()
		</script>
	</body>
</html>
